package com.gcit.seniorWish.web;

import com.gcit.seniorWish.web.config.properties.GunsProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * SpringBoot方式启动类
 *
 * @author stylefeng
 * @Date 2017/5/21 12:06
 */
@SpringBootApplication(scanBasePackages={"com.gcit.seniorWish"})
@EnableScheduling
public class SeniorWishApplication extends WebMvcConfigurerAdapter {
    protected final static Logger logger = LoggerFactory.getLogger(SeniorWishApplication.class);

    @Autowired
    GunsProperties gunsProperties;
    /**
     * 增加swagger的支持
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        if (gunsProperties.getSwaggerOpen()) {
            registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
            registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        }
    } 
    public static void main(String[] args) {
        SpringApplication.run(SeniorWishApplication.class, args);
        logger.info("吴中中考招生系统启动成功!");
    }
//@Bean  修改默认的dispatcherServlet
//public ServletRegistrationBean  servletRegistrationBean (DispatcherServlet dispatcherServlet){
//ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(dispatcherServlet);
//
//servletRegistrationBean.getUrlMappings().clear();
//servletRegistrationBean.addUrlMappings("*.do");
//return  servletRegistrationBean ;
//
//    }
}
